<?php
// +----------------------------------------------------------------------
// | TVSD  [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2023 http://xgx.517528.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: 王斌
// +----------------------------------------------------------------------

namespace app\admin\model\tvsd;

use think\Model;
use traits\model\SoftDelete;

class DdPc extends Model
{

    use SoftDelete;



    // 表名
    protected $name = 'dd_pc';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [
        'fs_text',
        'status1_text',
        'status_text'
    ];


    protected static function init()
    {
        self::afterInsert(function ($row) {
            $pk = $row->getPk();
            $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]);
        });
    }
    public function getFsList()
    {
        return ['现金' => __('现金'), '转账' => __('转账'), '其他' => __('其他')];
    }

    public function getStatusList()
    {
        return ['预定' => __('预定'), '确定' => __('确定')];
    }

    public function getStatus1List()
    {
        return ['未报销' => __('未报销'), '已报销' => __('已报销')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

    public function getFsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['fs']) ? $data['fs'] : '');
        $list = $this->getFsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStatus1TextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status1']) ? $data['status1'] : '');
        $list = $this->getStatus1List();
        return isset($list[$value]) ? $list[$value] : '';
    }
}
